package com.aims.server.controller;

import com.aims.api.dto.request.HelloRequest;
import com.aims.api.dto.response.HelloVO;
import com.aims.common.model.R;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * Hello 控制器
 */
@Slf4j
@Validated
@RestController
@RequestMapping("/api")
public class HelloController {

    /**
     * Hello 接口
     *
     * @param request 请求参数
     * @return 问候信息
     */
    @GetMapping("/hello")
    public R<HelloVO> hello(@Valid HelloRequest request) {
        log.info("Hello request: {}", request);

        HelloVO vo = new HelloVO();
        vo.setMessage("Hello, " + request.getName() + "!");
        vo.setTimestamp(System.currentTimeMillis());

        return R.success(vo);
    }
}